import { contextBridge, ipcRenderer } from 'electron';

contextBridge.exposeInMainWorld('electronAPI', {
    readDirectory: (path: string) => ipcRenderer.invoke('read-directory', path),
    createFolder: (parentPath: string, folderName: string) => ipcRenderer.invoke('create-folder', parentPath, folderName),
    renameFolder: (oldPath: string, newName: string) => ipcRenderer.invoke('rename-folder', oldPath, newName),
    deleteFolder: (folderPath: string) => ipcRenderer.invoke('delete-folder', folderPath),
    searchInDirectory: (folderPath: string, keyword: string) => ipcRenderer.invoke('search-in-directory', folderPath, keyword),
    openFileExternal: (filePath: string) => ipcRenderer.invoke('open-file-external', filePath),
    getFolderSteps: (rootPath: string, targetPath: string) => ipcRenderer.invoke('get-folder-steps', rootPath, targetPath),
    sendChunkToMain: (data: {name: string, path: string, chunk: Uint8Array, index: number, isFirst: boolean, isLast: boolean }[], targetDir: string) => ipcRenderer.send('upload-chunk', data),
});